import java.util.concurrent.CountDownLatch;

public class WorkingTask implements Runnable{
    private CountDownLatch c1;
    public WorkingTask(CountDownLatch c1){
        this.c1 = c1;
    }
    public void run(){
        try {
            System.out.println("现在运行的是:"+Thread.currentThread().getName());
            int r = (int)(Math.random()*10);
            long timeSpan = r*1000;
            Thread.sleep(timeSpan);
            System.out.println("运行"+r+"秒后，"+Thread.currentThread().getName() + "任务完成");
        } catch (InterruptedException e) {
            e.printStackTrace();
        }finally {
            this.c1.countDown();
        }
    }
}
